package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.activity.PublishStatusActivity;
import com.runen.infinitemovement.model.entity.AchievementEntity;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.imageview.RoundedCornersImage;
import com.runen.rxnetlibrary.utils.JsonUtils;

import java.util.List;

public class MyReflectionAdapter extends BaseQuickAdapter<AchievementEntity.DataBean, BaseViewHolder> {
    private Context context;

    public MyReflectionAdapter(Context context) {
        super(R.layout.item_my_reflection);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, AchievementEntity.DataBean item) {
        RoundedCornersImage rci_bg = helper.getView(R.id.rci_bg);
        ImageView iv_medalUrl = helper.getView(R.id.iv_medalUrl);
        GlideUtils.loadImage(context, item.cover, rci_bg);
        helper.setText(R.id.tv_start_end_name, item.startPoint + "-" + item.endPoint);
        helper.setText(R.id.tv_rank, String.valueOf(item.rank));
        helper.setText(R.id.tv_prize, item.prize);
        GlideUtils.loadImage(context, item.medalUrl, iv_medalUrl);
        ImageView iv_publish = helper.getView(R.id.iv_publish);
        iv_publish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, PublishStatusActivity.class);
                intent.putExtra("PUBLISH_FLAG",1);
                intent.putExtra("AchievementData", JsonUtils.toJson(item));
                context.startActivity(intent);
            }
        });
    }
}
